import request from '@/utils/request'

// 查询维修订单列表
export function listOrder(query) {
	return request({
		url: '/maintenance/order/list',
		method: 'get',
		params: query
	})
}
// 查询全部维修订单列表
export function allOrder(query) {
	return request({
		url: '/maintenance/order/all',
		method: 'get',
		params: query
	})
}

// 登录用户查询-维修订单列表
export function allUserOrder(query) {
	return request({
		url: '/maintenance/order/all/user',
		method: 'get',
		params: query
	})
}

// 查询维修订单详细
export function getOrder(orderId) {
	return request({
		url: '/maintenance/order/' + orderId,
		method: 'get'
	})
}

// 根据订单号 查询维修订单详细
export function getOrderNo(orderNo) {
	return request({
		url: '/maintenance/order/findOrderNo/' + orderNo,
		method: 'get'
	})
}

// 新增维修订单
export function addOrder(data) {
	return request({
		url: '/maintenance/order',
		method: 'post',
		data: data
	})
}

// 修改维修订单
export function updateOrder(data) {
	return request({
		url: '/maintenance/order',
		method: 'put',
		data: data
	})
}

// 删除维修订单
export function delOrder(orderId) {
	return request({
		url: '/maintenance/order/' + orderId,
		method: 'delete'
	})
}

// 订单接单
export function taskOrder(orderId) {
	return request({
		url: '/maintenance/order/receive/' + orderId,
		method: 'get'
	})
}


// 根据登录用户 获取订单数据
export function historyOrderUser() {
	return request({
		url: '/maintenance/order/history/user',
		method: 'get'
	})
}

// 获取工单趋势统计
export function getOrderTrend() {
	return request({
		url: '/maintenance/order/stats/trend',
		method: 'get'
	})
}

// 获取指定电梯历史维修记录
export function getHistoryByElevatorName(elevatorName) {
  return request({
    url: `/maintenance/order/history/${encodeURIComponent(elevatorName)}`,
    method: 'get'
  })
}